this.name					= "FuelStation-Setup";
this.author					= "Thargoid";
this.copyright				= "Creative Commons: attribution, non-commercial, sharealike.";
this.description				= "Script to add fuel station to certain systems";
this.version				= "1.21";

this.startUp = function()
	{
	this.extraA = true;	// for use with turretted ships - set to false to only get fuel satellites
	this.extraB = true;	// if set to false, no NPCs will use the stations (if extraA is false, has no effect)
	}

this.shipExitedWitchspace = function()
	{
	
	if(system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova) 
		{ // stop the script if interstellar space, or system is going Nova(to allow Nova mission unhindered) or indeed if it has gone nova already.
		return;
		}

	this.halfwayChance = 0.25; // 3 in 4 chance to add a station at the half-way point of route 1.
	this.witchpointChance = 0.33; // 2 in 3 chance to add a station near the witchpoint.

	if(missionVariables.longwayround == "STAGE1" || missionVariables.longwayround == "STAGE2")
		{ // drastically reduce the chances if you're in the middle of Long Way Round mission
		this.halfwayChance = 0.9; // 1 in 10 chance to add a station at the half-way point of route 1.
		this.witchpointChance = 0.95; // 1 in 20 chance to add a station near the witchpoint.
		}

	this.halfwayChance = 0; 
	this.witchpointChance = 0;

	if(system.government > 1 && system.techLevel > 3 && system.countShipsWithRole("fuelStation_location") == 0)
		{
		if(Math.random() > this.witchpointChance)
			{
			if(this.extraA && Math.random() > 0.33)
				{
	 			system.legacy_addShipsAt("fuelStation_station", 1, "pwu", [0.02, 0, 1]);
				}
			else
				{
	 			system.legacy_addShipsAt("fuelStation_satellite", 1, "pwu", [0.02, 0, 1]);
				}
			}

		if(Math.random() > this.halfwayChance)
			{
			if(this.extraA && Math.random() > 0.33)
				{
	 			system.legacy_addShipsAt("fuelStation_station", 1, "pwu", [0.02, 0, 0.5]);
				}
			else
				{
	 			system.legacy_addShipsAt("fuelStation_satellite", 1, "pwu", [0.02, 0, 0.5]);
				}
			}

		}
	}
